/*
 * @Description: 数据模型
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2022-11-22 17:00:14
 * @LastEditTime: 2023-01-11 09:33:34
 * @FilePath: \cscec-pms-admin\src\views\project\construction\model.js
 */

/**
 * @description: 限制整数
 * @param {number} value
 * @return {number}
 */
const limitNumber = (value) => {
  if (typeof value === 'string') {
    return !isNaN(Number(value)) ? value.replace(/\./g, '') : 0
  } else if (typeof value === 'number') {
    return !isNaN(value) ? String(value).replace(/\./g, '') : 0
  } else {
    return 0
  }
}
// 表单项
const formOption = [
  {
    label: '项目重要程度',
    keyName: 'importanceName',
    type: 'BaseInput',
    span: 12,
    disabled: true
  },
  {
    label: '节点等级',
    keyName: 'controlLevelName',
    type: 'BaseInput',
    span: 12,
    disabled: true
  },
  {
    label: '计划开始提示时间(天)',
    keyName: 'startTipDays',
    type: 'BaseInputNumber',
    span: 12,
    placeholder: '请输入计划开始提示时间',
    rules: [{ required: true, message: '请输入计划开始提示时间', trigger: 'change' }],
    attrs: {
      min: 0,
      formatter: limitNumber,
      parser: limitNumber
    }
  },
  {
    label: '计划结束提示时间(天)',
    keyName: 'endTipDays',
    type: 'BaseInputNumber',
    span: 12,
    placeholder: '请输入计划结束提示时间',
    rules: [{ required: true, message: '请输入计划结束提示时间', trigger: 'change' }],
    attrs: {
      min: 0,
      formatter: limitNumber,
      parser: limitNumber
    }
  },
  {
    label: '红灯亮灯时间(天)',
    keyName: 'redTipDays',
    type: 'BaseInputNumber',
    span: 12,
    placeholder: '请输入红灯亮灯时间',
    rules: [{ required: true, message: '请输入红灯亮灯时间', trigger: 'change' }],
    attrs: {
      min: 0,
      formatter: limitNumber,
      parser: limitNumber
    }
  },
  {
    label: '黄灯亮灯时间(天)',
    keyName: 'yellowTipDays',
    type: 'BaseInputNumber',
    span: 12,
    placeholder: '请输入黄灯亮灯时间',
    rules: [{ required: true, message: '请输入黄灯亮灯时间', trigger: 'change' }],
    attrs: {
      min: 0,
      formatter: limitNumber,
      parser: limitNumber
    }
  }
]
// 表头
const columns = [
  {
    title: '通知岗位',
    dataIndex: 'noticePost',
    width: '50%',
    scopedSlots: { customRender: 'noticePost' }
  },
  {
    title: '通知方式',
    dataIndex: 'msg',
    scopedSlots: { customRender: 'msg' }
  }
]
// 通知选项
const msgOptions = [
  {
    value: 'notice',
    label: 'PC端'
  },
  {
    value: 'jiguangPush',
    label: 'APP端'
  },
  {
    value: 'jiguangSms',
    label: '短信'
  },
]
export {
  formOption,
  columns,
  msgOptions
}
